<%@page pageEncoding="utf-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Book Store</title>
<link rel="stylesheet" type="text/css" href="style.css" />
    <script type="text/javascript">
        function selectall() {
            var checkBoxes = document.getElementsByName("id");
            if (document.getElementById("all").checked) {
                for ( var i = 0; i < checkBoxes.length; i++) {
                    checkBoxes[i].checked = true;
                }
            } else {
                for ( var i = 0; i < checkBoxes.length; i++) {
                    checkBoxes[i].checked = false;
                }
            }

        }


        //删除选中图书
        function deleteSelectedBook(id) {
            var r = confirm("确定要删除选中的图书吗?");

            if(r){
                var checks = document.getElementsByName("id");
                var count = 0;
                var ids = "";

                for (var i = 0; i < checks.length; i++) {
                    if (checks[i].checked) {
                        count++;
                        ids += checks[i].value + ":";
                    }
                }

                if(count == 0){
                    if(id == ''){
                        alert("至少选择一个...");
                        return;
                    }else{
                        ids = id;
                    }
                }
                //ajax请求,把ids传到后台
                var xmlhttp;
                if(window.XMLHttpRequest){
                    xmlhttp = new XMLHttpRequest();
                }else{
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                var url = "deleteitem.action?ids=" + ids;
                xmlhttp.open("GET",url,true);
                xmlhttp.send();

                xmlhttp.onreadystatechange=function(){
                    if(xmlhttp.readyState==4 && xmlhttp.status==200){
                        var txt = xmlhttp.responseText;
                        if(txt == "1"){
                            alert("删除成功!");
                            window.location.reload(true);

                        }else{
                            alert("删除失败!");
                        }
                    }
                };
            }
        }


        function updatecount(id){

            var c = document.getElementById(id).value;
            var xmlhttp;
            if(window.XMLHttpRequest){
                xmlhttp = new XMLHttpRequest();
            }else{
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            var url = "updatecount.action?bookId=" + id+"&count="+c;
            xmlhttp.open("GET",url,true);
            xmlhttp.send();

            xmlhttp.onreadystatechange=function(){
                if(xmlhttp.readyState==4 && xmlhttp.status==200){
                    var txt = xmlhttp.responseText;
                    if(txt == "1"){
                        alert("修改成功!");
                        window.location.reload(true);

                    }else{
                        alert("修改失败!");
                        window.location.reload(true);
                    }
                }
            };

        }



    </script>
</head>
<body>
<div id="wrap">

       <div class="header">
       		<div class="logo"><a href="index.html"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
        <div id="menu">
            <ul>                                                                       
            <li class="selected"><a href="index.jsp">首页</a></li>
            
            <li><a href="category.action">图书</a></li>
            <li><a href="specials.action">特价图书</a></li>
            <li><a href="myaccount.action">登陆</a></li>
            <li><a href="register.action">注册</a></li>
            <!--<li><a href="details.html">prices</a></li>-->
            <li><a href="about.action">我的订单</a></li>
            <li><a href="about.action">关于我们</a></li>
            <li><a href="contact.action">联系我们</a></li>
            </ul>
        </div>           
            
            
       </div> 
       
       
       <div class="center_content">
       	<div class="left_content">
            <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>我的购物车</div>
        
        	<div class="feat_prod_box_details">
            
            <table class="cart_table">
            	<tr class="cart_title">
                	<td><input type="checkbox" id="all" onclick="selectall()"/></td>
                	<td>图片</td>
                	<td>书名</td>
                    <td>单价</td>
                    <td>数量</td>
                    <td>合计</td>               
                </tr>


                <s:if test="#session.cart.count!=0">
                <s:iterator value="#session.cart.items">
            	<tr>
                	<td><input type="checkbox" name="id" value="<s:property value="book.bookId"/>"/></td>
                	<td><a href="details.html"><img src="images/cart_thumb.gif" alt="" title="" border="0" class="cart_thumb" /></a></td>
                	<td><s:property value="book.bookName"/></td>
                    <td><s:property value="book.price"/>元</td>
                    <td><input type="text" name="count" value="<s:property value="count"/>" style="width:30px; text-align:center" /></td>
                    <td><s:property value="totalPrice"/>$</td>
                </tr>

                </s:iterator>
                </s:if>
                <s:else>
                    <td colspan="4"><span>暂无图书！</span></td>
                </s:else>

                <tr>
                <td colspan="4" class="cart_total"><span class="red">总价:</span></td>
                <td><s:property value="#session.cart.totalPrice"/>$</td>
                </tr>  


              
            </table>
            <a href="index.action" class="continue">&lt; <继续买</a>
            <a href="confirm_order.action" class="checkout">结算</a>
            <a href="clear.action" class="checkout" >清空</a>
            <a href="javascript:void(0)" class="checkout" onclick="deleteSelectedBook('')">删除</a>



            </div>	
            
              

            

            
        <div class="clear"></div>
        </div><!--end of left content-->
        
        <div class="right_content">
        
                	<div class="languages_box">
            <span class="red">Languages:</span>
            <a href="#"><img src="images/gb.gif" alt="" title="" border="0" /></a>
            <a href="#"><img src="images/fr.gif" alt="" title="" border="0" /></a>
            <a href="#"><img src="images/de.gif" alt="" title="" border="0" /></a>
            </div>
                <div class="currency">
                <span class="red">Currency: </span>
                <a href="#">GBP</a>
                <a href="#">EUR</a>
                <a href="#"><strong>USD</strong></a>
                </div>
                
                
              <div class="cart">
                  <div class="title"><span class="title_icon"><img src="images/cart.gif" alt="" title="" /></span>我的购物车</div>
                  <div class="home_cart_content">
                  3个商品 | <span class="red">总价: 100$</span>
                  </div>
                  <a href="cart.html" class="view_cart">查看购物车</a>
              
              </div>
        
             <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>关于我们店</div> 
             <div class="about">
             <p>
             <img src="images/about.gif" alt="" title="" class="right" />
             本书店是天创集团旗下的天智教育经营的书店，开业十年来，一直与国内外五百家出版社，近千家发行单位保持着良好的合作关系。以其集文化传播、艺术鉴赏、休闲为一体的崭新经营方式、一流的购书环境及优质的服务，赢得了众多的荣誉，成为华东地区最大的集图书、音像制品、文化用品、快餐、软件开发、广告策划于一体的图书零售企业。
             </p>
             
             </div>
             
             <div class="right_box">
             
             	<div class="title"><span class="title_icon"><img src="images/bullet4.gif" alt="" title="" /></span>推荐图书</div> 
                    <div class="new_prod_box">
                        <a href="details.html">平凡的世界</a>
                        <div class="new_prod_bg">
                        <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                        <a href="details.html"><img src="images/thumb1.gif" alt="" title="" class="thumb" border="0" /></a>
                        </div>           
                    </div>
                    
                    <div class="new_prod_box">
                        <a href="details.html">穆斯林葬礼</a>
                        <div class="new_prod_bg">
                        <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                        <a href="details.html"><img src="images/thumb2.gif" alt="" title="" class="thumb" border="0" /></a>
                        </div>           
                    </div>                    
                    
                    <div class="new_prod_box">
                        <a href="details.html">围城</a>
                        <div class="new_prod_bg">
                        <span class="new_icon"><img src="images/promo_icon.gif" alt="" title="" /></span>
                        <a href="details.html"><img src="images/thumb3.gif" alt="" title="" class="thumb" border="0" /></a>
                        </div>           
                    </div>               
             
             </div>
             
             <div class="right_box">
             
             	<div class="title"><span class="title_icon"><img src="images/bullet5.gif" alt="" title="" /></span>图书分类</div> 
                
                <ul class="list">
                <li><a href="#">accesories</a></li>
                <li><a href="#">books gifts</a></li>
                <li><a href="#">specials</a></li>
                <li><a href="#">hollidays gifts</a></li>
                <li><a href="#">accesories</a></li>
                <li><a href="#">books gifts</a></li>
                <li><a href="#">specials</a></li>
                <li><a href="#">hollidays gifts</a></li>
                <li><a href="#">accesories</a></li>
                <li><a href="#">books gifts</a></li>
                <li><a href="#">specials</a></li>                                              
                </ul>
                
             	<div class="title"><span class="title_icon"><img src="images/bullet6.gif" alt="" title="" /></span>合作伙伴</div> 
                
                <ul class="list">
                <li><a href="#">accesories</a></li>
                <li><a href="#">books gifts</a></li>
                <li><a href="#">specials</a></li>
                <li><a href="#">hollidays gifts</a></li>
                <li><a href="#">accesories</a></li>
                <li><a href="#">books gifts</a></li>
                <li><a href="#">specials</a></li>
                <li><a href="#">hollidays gifts</a></li>
                <li><a href="#">accesories</a></li>                              
                </ul>      
             
             </div>         
             
        
        </div><!--end of right content-->
        
        
       
       
       <div class="clear"></div>
       </div><!--end of center content-->
       
              
       <div class="footer">
       	<div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /><br /> <a href="http://csscreme.com"><img src="images/csscreme.gif" alt="by csscreme.com" title="by csscreme.com" border="0" /></a></div>
        <div class="right_footer">
        <a href="#">home</a>
        <a href="#">about us</a>
        <a href="#">services</a>
        <a href="#">privacy policy</a>
        <a href="#">contact us</a>
       
        </div>
        
       
       </div>
    

</div>

</body>
</html>